package br.com.caelum.vraptor.dao;

import javax.persistence.NoResultException;

import br.com.caelum.vraptor.entidades.Professor;

public class ProfessorDAO extends GenericJPADAO<Professor> {

	public ProfessorDAO() {
	
		this.persistentClass = Professor.class;	
	}
	public Professor find(String matricula, String senha){
	 try{
         Professor prof = getEm().createQuery("select p from professor p where p.matricula = :matricula and p.senha = :senha", Professor.class)
                         .setParameter("matricula", matricula)
                         .setParameter("senha", senha)
                         .getSingleResult();
         return prof;
         }
 catch(NoResultException e){ return null; 
 		}
	
	}

}
